﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;

namespace Extjs_ReGSharp.InputParsing
{
	internal class PageDataExtractor<T>
	{
		#region Consts

		private const string StartIndexParameter = "start";
		private const string LimitParameter = "limit";

		#endregion

		#region Data Memebers

		private NameValueCollection m_InputParameters;

		#endregion

		#region Private Methods

		private PageData<T> ExtractPageDataFromParameters()
		{
			int startIndex = Int32.Parse(m_InputParameters[StartIndexParameter]);

			int limit = Int32.Parse(m_InputParameters[LimitParameter]);

			PageData<T> result = new PageData<T>() { StartIndex = startIndex, Limit = limit };

			return result;
		}

		#endregion

		#region Constructor

		internal PageDataExtractor(NameValueCollection inputParameters)
		{
			m_InputParameters = inputParameters;
		}

		#endregion

		#region Public Methods

		internal PageData<T> ExtractPageData()
		{
			PageData<T> result = ExtractPageDataFromParameters();

			return result;
		}

		#endregion
	}
}
